var rootSiteUrl = 'default.aspx';
$(document).ready(function() {
  
   var showDialog = true; 
   if (jaaulde.utils.cookies.get('shangxu.org')=='nanxiaoJie')
   {
     showDialog = false;
   }
   else if (jaaulde.utils.cookies.get('shangxu.org') != null)
   {
      jaaulde.utils.cookies.del('shangxu.org');   
   }
   if (showDialog)
   {
     $("#dialog").dialog({
          bgiframe: true,
          autoOpen: false,
          resizable: false,
          draggable: false,
          modal: true,
          width: 600,
          buttons: {
             'Ok': function()
             {
              var answer =  $().crypt({method:"md5",source:$('#answer').val().toUpperCase()}); 
                  if ( answer != '3b5949e0c26b87767a4752a276de9570' && answer != '600db333f1411354ade32da19b83e63e')
                  {
                    alert("Who are you? <BR />Please <a href='protected.aspx'>try again</a> or <a href='http://wolf-shadow77.deviantart.com/art/Ha-Ha-GET-OUT-208017873'>get help</a>.", function () { window.location.href = rootSiteUrl; });
                  }
                  else
                  {
                   jaaulde.utils.cookies.set('shangxu.org', 'nanxiaoJie');
                   $(this).dialog('close');
                  }
             },
             'Cancel': function()
             {
                window.location.href = rootSiteUrl;
             }
          },
          open: function()
          {
             $(this).parent().find(".ui-dialog-titlebar-close").toggle(false);
          },
          close: function() {}
       }).dialog('open');
       
       $('#answer').bind('keydown', function () {
         if (event.keyCode == 13) $($(':button')[0]).click();
    });
   } 
   
});
